package org.agile4j.patterns.adapter;

import org.agile4j.patterns.adapter.logversion01.ILogFileOperate;
import org.agile4j.patterns.adapter.logversion01.LogFileOperateImpl;

import java.text.SimpleDateFormat;
import java.util.*;

public class AdapterDemo {
	public static void main(String[] args) {
		List<LogModel> all = new ArrayList<LogModel>();
		
		System.out.println(Calendar.getInstance().getTime());
		System.out.println(new Date());
//		87d7df45d3be466fa598874cdabe4ad3
		
		LogModel log = new LogModel();
		log.setLogId("101010");
		log.setOperater("hanyx");
		log.setOperateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		log.setLogContent(UUID.randomUUID().toString());
		all.add(log);
		
		LogModel log1 = new LogModel();
		log1.setLogId("101011");
		log1.setOperater("sunny");
		log1.setOperateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		log1.setLogContent(UUID.randomUUID().toString());
		all.add(log1);
		
		// 创建日志文件操作对象
		ILogFileOperate api = new LogFileOperateImpl("");
		// 写入日志
		api.writeLogFile(all);
		// 读取日志
		List<String> list = api.readLogFile();
		Iterator<String> ite = list.iterator();
		while (ite.hasNext()) {
			System.out.println(ite.next());
		}
	}
}
